﻿
<%@ Page Title="" Language="C#" MasterPageFile="~/Presentation/master.Master" AutoEventWireup="true" CodeBehind="PurchaseOrders.aspx.cs" Inherits="StationeryInv.PurchaseOrders" EnableEventValidation ="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">


        <div class = "row" align = "center" >
            <h2 class="style1">
                <strong>LOGIC University<br />
                <span class="style2">Stationery Purchase Order</span></strong></h2>
           </div>
           
           <br />

 <div class = "row">
        <asp:Label ID="lblPurchaseOrderNo" runat="server" CssClass="col-md-4 text-info" Text="Purchase Order Number"></asp:Label> &nbsp;<asp:TextBox ID="tbPONumber" runat="server" style="text-align: center" CssClass="col-sm-8 text-info"
            ReadOnly="True">Auto Gen PO No</asp:TextBox>
       
    </div>

    <br />
    <br />

    <div class = "row">
        <asp:Label ID="lblSupplierName" runat="server" CssClass="col-md-4 text-info" Text="Supplier Name"></asp:Label>
        &nbsp;<asp:DropDownList ID="ddlSupplier"  runat="server" CssClass="col-sm-8 text-info"
            DataSourceID="SqlDataSourceSupplierNames" DataTextField="Name" 
            DataValueField="Name" AutoPostBack="True" onselectedindexchanged="ddlSupplier_SelectedIndexChanged1" 
            >
            <asp:ListItem Selected="True"></asp:ListItem>
        </asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSourceSupplierNames" runat="server" 
            ConnectionString="<%$ ConnectionStrings:InvManagementConnectionString %>" 
            SelectCommand="SELECT [Name] FROM [Supplier]"></asp:SqlDataSource>
   </div>

<br />
<br />


<div class ="row">
        <asp:Label ID="lblDeliverytoWhere" runat="server" CssClass="col-sm-4 text-info" Text="Deliver To"></asp:Label>
&nbsp;<asp:Label ID="lblDeliverTo" runat="server" CssClass="col-sm-8 text-info" Font-Bold="True" 
            Text="LOGIC Uni / Inventory Dept"></asp:Label>
            </div>

        <br/>
        <br />
        
        <div class = "row">
        <asp:Label ID="lblAttentionTo" runat="server" CssClass="col-sm-4 text-info" Text="Attention"></asp:Label>
            <span class="style3">&nbsp;</span><asp:Label ID="lblAttnTo" runat="server" CssClass="col-sm-8 text-info" Font-Bold="True" 
            Text="Person who Orders this PO"></asp:Label>

            </div>
 <br />
 <br />
   
 <div class = "row">
        <asp:Label ID="lblRequiredDate" runat="server" CssClass="col-md-7 text-info"
            Text="Please Supply the Following Items By"></asp:Label>
        &nbsp;<asp:TextBox ID="tbReqDate" runat="server" CssClass="col-sm-5 text-info" Font-Bold="True" 
            style="text-align: center" Width="250px">Enter Required Date Here</asp:TextBox>
            </div>
    <br />
    <br />
   
   <div class = "row">
        <asp:Button ID="btnShowSuggestions" runat="server" Text="Show Suggestions" CssClass="btn btn-default"
            onclick="btnShowSuggestions_Click" CausesValidation="False" />
            </div>

    <br />
    <br />

    
    <div class = "row">
        <asp:GridView ID="GviewPO" runat="server" CssClass="col-sm-12 table table-striped table-bordered table-hover" AutoGenerateColumns ="False">
            <Columns>
                <asp:BoundField DataField="ItemID" HeaderText="Item ID" />
                <asp:BoundField DataField="Description" HeaderText="Description" />
                <asp:TemplateField HeaderText="Quantity">
                    <ItemTemplate>
                        <asp:TextBox ID="QtyPO" onkeypress="Synctextbox()" runat="server" Text='<%# Eval("Qty") %>' 
                            ClientIDMode="Static" ontextchanged="QtyPO_TextChanged" 
                            AutoPostBack="True" ></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Price($)">
                    <ItemTemplate>
                        <asp:TextBox ID="UnitPrice" Text='<%# Eval("Price") %>' runat="server" 
                            ReadOnly="True"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Amount($)">
                    <ItemTemplate>
                        <asp:TextBox ID="SubtotalAmount" Text='<%# Eval("Amount") %>'  runat="server" 
                            ReadOnly="True" ></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView> 
        </div>
     
   
       <div class = "row">
        <asp:RequiredFieldValidator ID="valreqSupplyItemsBy" runat="server"  CssClass="col-sm-12 text-info"
            ControlToValidate="tbReqDate" ErrorMessage="Date to Supply items is Required" 
            ForeColor="#FF6600"></asp:RequiredFieldValidator>
            </div>
   <br />
   
   <div class = "row">
        <asp:RegularExpressionValidator ID="valregSupplyItemsBy" runat="server" CssClass="col-sm-12 text-info"
            ControlToValidate="tbReqDate" ErrorMessage="Enter A Valid Date of DD/MM/YYYY to supply by when:" 
            ForeColor="Red" 
            ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d"></asp:RegularExpressionValidator>
   
    </div>
    <br />

     <div class ="row">
        <asp:RegularExpressionValidator ID="valregOrderDate" runat="server" CssClass="col-sm-12 text-info"
            ControlToValidate="tbOrderedDate" 
            ErrorMessage="Enter a DD/MM/YYYY for Ordered by:" ForeColor="Red" 
            ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d"></asp:RegularExpressionValidator>
    </div>
    <br />

      <div class ="row">
     <asp:RegularExpressionValidator ID="valregApproveDate" runat="server" CssClass="col-sm-12 text-info"
            ControlToValidate="tbApprovedDate" 
            ErrorMessage="Enter a DD/MM/YYYY for Approved Date" ForeColor="Red" 
            
              ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d"></asp:RegularExpressionValidator>
   </div>
    <br />

  
  <div class ="row">
    <h3>
        <asp:Label ID="lblTotalPrice" runat="server" CssClass="col-md-6 text-info" Text="Total Price($)"></asp:Label>
        <asp:TextBox ID="tbGrandTotal" CssClass="col-md-6 text-info" runat="server" Font-Bold="True" 
            style="text-align: center; top: 0px; left: 0px; width: 365px;" 
            ReadOnly="True"> Grand Total for All Goods</asp:TextBox>
    </h3>
    </div>

    <br />
    <br />

    
    

    <div class = "row">
  
        <asp:Label ID="lblOrderedBy" runat="server" CssClass="col-sm-3 text-info" Text="Ordered By"></asp:Label>
        &nbsp;&nbsp;
        <asp:DropDownList ID="ddlOrderedBy" CssClass="col-sm-3 text-info" runat="server" 
            DataSourceID="SqlDataSourceOrderedBy" DataTextField="Name" 
            DataValueField="Name" onload="ddlOrderedBy_Load">
            <asp:ListItem></asp:ListItem>
        </asp:DropDownList>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:Label 
            ID="lblOrderDate" runat="server" CssClass="col-sm-3 text-info" Text="Date"></asp:Label>
        &nbsp;<asp:TextBox ID="tbOrderedDate" runat="server" CssClass="col-sm-3 text-info">Ordered Date</asp:TextBox>

    </div>
    <br />
    <br />

    <div class = "row">
        <asp:Label ID="lblApprovedBy" runat="server" CssClass="col-sm-3 text-info" Text="Approved By"></asp:Label>
&nbsp;<asp:DropDownList ID="ddlApprovedBy" runat="server" CssClass="col-sm-3 text-info" 
            DataSourceID="SqlDataSourceApprovedBy" DataTextField="Name" 
            DataValueField="Name">
            <asp:ListItem></asp:ListItem>
        </asp:DropDownList>

        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

        <asp:Label 
            ID="lblApproveDate" runat="server" CssClass="col-sm-3 text-info" Text="Date"></asp:Label>
        &nbsp;
        <asp:TextBox ID="tbApprovedDate" CssClass="col-sm-3 text-info" runat="server">Approval Date</asp:TextBox>
   </div>
   <br />
   <br />

    <asp:SqlDataSource ID="SqlDataSourceOrderedBy" runat="server" 
        ConnectionString="<%$ ConnectionStrings:InvManagementConnectionString %>" 
        
        
            SelectCommand="SELECT [Name], [Role] FROM [Employee] WHERE (([DeptID] = @DeptID) AND ([Role] = @Role))">
        <SelectParameters>
            <asp:Parameter DefaultValue="310002" Name="DeptID" Type="Int32" />
            <asp:Parameter DefaultValue="Employee" Name="Role" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSourceApprovedBy" runat="server" 
        ConnectionString="<%$ ConnectionStrings:InvManagementConnectionString %>" 
        
        
            SelectCommand="SELECT DISTINCT [Name], [Role] FROM [Employee] WHERE (([DeptID] = @DeptID) AND ([Role] &lt;&gt; @Role3))">
        <SelectParameters>
            <asp:Parameter DefaultValue="310002" Name="DeptID" Type="Int32" />
            <asp:Parameter DefaultValue="Employee" Name="Role3" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <br />

    <div class = "row">
    <div class="col-md-2">
    <asp:Button ID="btnAddItem" CssClass="btn btn-default" runat="server" Text="Add Item" 
            onclick="btnAddItem_Click" />
            </div>

   <div class="col-md-3">
        <asp:Button ID="btnSubmitToSupplier" CssClass="btn btn-primary"  runat="server" Text="Submit to Supplier" 
            onclick="btnSubmitToSupplier_Click" />
            </div>

 <div class="col-md-2">
        <asp:Button ID="btnClearFields" CssClass="btn btn-default" runat="server" Text="Clear Fields" 
            onclick="btnClearFields_Click" />
            </div>

    </div>
    <br />


   
<%-- <script type="text/javascript">
     function toggleDropDownList(source) {
         document.getElementById('<%= ddlSupplier.ClientID %>').disabled 
     }
</script>--%>



    
</asp:Content>